package com.suirich.service.impl;

import java.io.UnsupportedEncodingException;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.suirich.bean.ContactUs;
import com.suirich.service.BaseService;
import com.suirich.service.ContactUsService;

@Service
@Transactional
public class ContactUsServiceImpl extends BaseService implements ContactUsService {

	public void create(ContactUs contactUs) {
		this.contactUsDao.create(contactUs);
	}

    public ContactUs read(Long id) {
    	ContactUs contactUs = this.contactUsDao.read(id);
    	if(contactUs != null){
            try {
                String contentInfo = "";
                byte[] b = (byte[])contactUs.getContent();
                
                if(b != null){
                	contentInfo = new String(b,"UTF-8");
                }else{
                	contentInfo = "No content！";
                }
                contactUs.setContentInfo(contentInfo);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
    	}
        return contactUs;
    }
    
    public void update(ContactUs contactUs) {
        this.contactUsDao.update(contactUs);
    }

}
